#ifndef GLOVE_VOLT_SENSOR_STATE_H
#define GLOVE_VOLT_SENSOR_STATE_H

#include "state.h"


class volt_sensor_state : public state
{
public:
   volt_sensor_state(int in);

   virtual void on_enter();
   virtual void on_update();
   virtual void on_leave();

private:
   const int input_pin;

   static const int16_t speaker_freq = 2200;
   static const int16_t speaker_time = 100;

   static const int16_t sample_range_threshold = 10;
   static const int16_t sample_high_threshold = 10;
   static const int16_t samples_size = 10;
   int16_t samples[samples_size];
   int16_t sample_index;
   int16_t sample_min;
   int16_t sample_max;
   int16_t sample_high_count;

   int32_t last_zero_at;
};

#endif

